package com.hs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.Article;
import com.hs.mapper.ArticleMapper;
import com.hs.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ArticleServiceImpl
 * @Description TODO
 * @Author libowen
 * @Date 2025年08月01日 10:48
 * @Version 1.0
 */
@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    @Override
    public int addArticle(Article article) {
        return articleMapper.addArticle(article);
    }

    @Override
    public int deleteArticleById(int id) {
        return articleMapper.deleteArticleById(id);
    }

    @Override
    public int deleteArticleByIds(int[] ids) {
        return articleMapper.deleteArticleByIds(ids);
    }

    @Override
    public int updateArticle(Article article) {
        return articleMapper.updateArticle(article);
    }

    @Override
    public Article getArticleById(int id) {
        return articleMapper.getArticleById(id);
    }

    @Override
    public PageInfo<Article> getAllArticle(Article article, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Article> list = articleMapper.getAllArticle(article);
        PageInfo<Article> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
